﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;

namespace TA.Turbo.Controls
{
	[ParseChildren(true)]
	[PersistChildren(false)]
	public class TurboProgress : BasePopupControl
	{
		public TurboProgress()
		{
			InclusionMode = InclusionMode.AllExceptExcluded;
		}
		public int DisplayTimeout { get; set; }
		public InclusionMode InclusionMode { get; set; }
		public string Scenarios { get { return _mpvScenarios.Value; } set { _mpvScenarios.Value = value; } }
		public List<string> ScenarioList { get { return _mpvScenarios.ValueList; } }
		#region INTERNAL
		MultiPartValue _mpvScenarios = new MultiPartValue();
		protected override void OnInit(EventArgs e)
		{
			base.OnInit(e);

			TurboPage.Current.Includes.Add(new ScriptResourceInclude
			{
				TypeName = this.GetType().FullName,
				Resource = "TA.Turbo.Resources.JS.TurboProgress.js"
			});

			TurboPage.Current.ProgressControls.Add(this);
		}
		protected override void AddAttributesToRender(HtmlTextWriter writer)
		{
			writer.AddAttribute("DisplayTimeout", DisplayTimeout.ToString());
			base.AddAttributesToRender(writer);
		}
		protected override void RenderInitScriptInternal(HtmlTextWriter writer)
		{
			writer.Write(string.Format("(new TA.Turbo.Controls.TurboProgress(\"{0}\")).Init();", ClientID));
		}

		#endregion
	}
}
